

using System.Linq;
using Abp.Authorization;
using Abp.Configuration.Startup;
using Abp.Localization;
using Abp.MultiTenancy;
using Yozeev.BusinessLogic.Authorization;
using Yozeev.Authorization;

namespace Yozeev.Authorization
{
    /// <summary>
    /// 权限配置都在这里。
    /// 给权限默认设置服务
    /// See <see cref="TicketRolePermissions" /> for all permission names. TicketRole
    ///</summary>
    public class TicketRoleAuthorizationProvider : AuthorizationProvider
    {
        private readonly bool _isMultiTenancyEnabled;

		public TicketRoleAuthorizationProvider()
		{

		}

		public TicketRoleAuthorizationProvider(bool isMultiTenancyEnabled)
		{
			_isMultiTenancyEnabled = isMultiTenancyEnabled;
		}


		public TicketRoleAuthorizationProvider(IMultiTenancyConfig multiTenancyConfig)
        {
            _isMultiTenancyEnabled = multiTenancyConfig.IsEnabled;
        }

		public override void SetPermissions(IPermissionDefinitionContext context)
		{
			// 在这里配置了TicketRole 的权限。
			var pages = context.GetPermissionOrNull(AppPermissions.Pages) ?? context.CreatePermission(AppPermissions.Pages, L("Pages"));

			var administration = pages.Children.FirstOrDefault(p => p.Name == AppPermissions.Pages_Administration) ?? pages.CreateChildPermission(AppPermissions.Pages_Administration, L("Administration"));

			var entityPermission = administration.CreateChildPermission(TicketRolePermissions.Node , L("TicketRole"));
			entityPermission.CreateChildPermission(TicketRolePermissions.Query, L("QueryTicketRole"));
			entityPermission.CreateChildPermission(TicketRolePermissions.Create, L("CreateTicketRole"));
			entityPermission.CreateChildPermission(TicketRolePermissions.Edit, L("EditTicketRole"));
			entityPermission.CreateChildPermission(TicketRolePermissions.Delete, L("DeleteTicketRole"));
			entityPermission.CreateChildPermission(TicketRolePermissions.BatchDelete, L("BatchDeleteTicketRole"));
			entityPermission.CreateChildPermission(TicketRolePermissions.ExportExcel, L("ExportToExcel"));

			
							//// custom codes
									
							

							//// custom codes end
		}

		private static ILocalizableString L(string name)
		{
			return new LocalizableString(name, AppConsts.LocalizationSourceName);
		}
    }
}